package chapter11;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

public class AddingGroups {
	public static void main(String[] args) {
		Collection<Integer> collection = 
				new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5));
		Integer[] moreInts = {6, 7, 8, 9, 10};
		collection.addAll(Arrays.asList(moreInts));
		Collections.addAll(collection, 11, 12, 13, 14, 15);
		Collections.addAll(collection, moreInts);
		moreInts = collection.toArray(new Integer[1]);
		System.out.println(moreInts[1]);
		int i = 1;
		for(Integer c: collection) {
			System.out.print(String.format("%4d", c));
			if(i++ % 5 == 0)
				System.out.println();
		}
		
		List<Integer> list = Arrays.asList(16, 17, 18, 19, 20);
		list.set(1, 99);
		System.out.println(list);
	}
}
